<template>
  <el-main style=" width:100%; overflow:hidden">
    <el-form label-width="120px">
      <el-row>
        <!-- 课程名称 -->
        <el-col :span="12">
          <el-form-item label="课程名称">
            <el-input
              v-model="courseData.title"
              :readonly="true"
              size="small"
              class
            />
          </el-form-item>
        </el-col>
        <!-- 课程类别 -->
        <el-col :span="12">
          <el-form-item label="课程类别">
            <el-input
              v-model="courseData.courseTypeName"
              size="small"
              :readonly="true"
            />
          </el-form-item>
        </el-col>
        <!-- 年份 -->
        <el-col :span="12">
          <el-form-item label="年份">
            <el-input
              v-model="courseData.year"
              :readonly="true"
              size="small"
              class
            />
          </el-form-item>
        </el-col>
        <!-- 学期 -->
        <el-col :span="12">
          <el-form-item label="学期">
            <el-input v-model="courseData.term" size="small" :readonly="true" />
          </el-form-item>
        </el-col>
        <!-- 总学时 -->
        <el-col :span="12">
          <el-form-item label="总学时">
            <el-input
              v-model="courseData.classHours"
              :readonly="true"
              size="small"
              class
            />
          </el-form-item>
        </el-col>
        <!-- 总学分 -->
        <el-col :span="12">
          <el-form-item label="总学分">
            <el-input
              v-model="courseData.credits"
              size="small"
              :readonly="true"
            />
          </el-form-item>
        </el-col>
        <!-- 上课时间和地方 -->
        <el-col :span="24" style="margin-left:30px">
          <!-- <el-form-item label="上课时间与地点"> -->
          <el-table
            class="courseData"
            :data="courseData.timePlace"
            border
            style="width: 100%"
            :header-cell-style="{
              background: '#94AFCC',
              color: '#1A1C1E',
              padding: '0',
              height: '10px',
            }"
            :row-style="{ height: '10px', padding: '0px' }"
            :cell-style="{ padding: '0px' }"
          >
            <el-table-column prop="time" label="时间"></el-table-column>
            <el-table-column prop="buildingId" label="楼栋"></el-table-column>
            <el-table-column prop="roomNumber" label="课室"></el-table-column>
          </el-table>
          <!-- </el-form-item> -->
        </el-col>
      </el-row>
    </el-form>
    <el-button
      type="text"
      style="margin-left:30px;margin-top:10px"
      @click="dialogVisible = true"
      >查看上课学生列表</el-button
    >
    <el-dialog
      title="课程学生信息列表"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="771px"
      center
    >
      <el-main style="padding:10px;text-align:center">
        <el-table
          class="studentTable"
          :data="courseStudentData"
          height="250"
          border
          :header-cell-style="{
            background: '#94AFCC',
            color: '#333333',
            padding: '0',
            height: '30px',
            fontSize: '12px',
            textAlign: 'center',
            fontWeight: '700',
          }"
          :row-style="{ height: '25px', padding: '0px' }"
          :cell-style="{
            padding: '0px',
            textAlign: 'center',
            fontSize: '12px',
            height: '30px',
            color: '#333333',
          }"
        >
          <el-table-column
            prop="studentId"
            label="学号"
            :resizable="false"
            width="110"
          ></el-table-column>
          <el-table-column
            prop="name"
            label="姓名"
            :resizable="false"
            width="70"
          ></el-table-column>
          <el-table-column
            prop="male"
            label="性别"
            :resizable="false"
            width="50"
          ></el-table-column>
          <el-table-column
            prop="departmentName"
            label="所属院系"
            :resizable="false"
            width="90"
          ></el-table-column>
          <el-table-column
            prop="enrollmentYear"
            label="所在年级"
            :resizable="false"
            width="80"
          ></el-table-column>
          <el-table-column
            prop="majorName"
            label="所属专业"
            :resizable="false"
            width="90"
          ></el-table-column>
          <el-table-column
            prop="className"
            label="所在班级"
            :resizable="false"
            width="90"
          ></el-table-column>
          <el-table-column
            prop="phoneNumber"
            label="联系方式"
            :resizable="false"
          ></el-table-column>
        </el-table>
      </el-main>
    </el-dialog>
  </el-main>
</template>

<script>
export default {
  data() {
    return {
      courseData: {
        // title: "测试",
        // courseTypeName: "测试",
        // year: "测试",
        // term: "测试",
        // classHours: 64,
        // credits: 3.5,
        // Teacher: null,
        // timePlace: [
        //   {
        //     time: "星期二 1-3节",
        //     buildingId: "A1",
        //     roomNumber: "101",
        //   },
        //   {
        //     time: "星期三 2-4节",
        //     buildingId: "A2",
        //     roomNumber: "103",
        //   },
        // ],
      },
      // 弹窗显示上课学生列表
      dialogVisible: false,
      // 上课学生列表
      courseStudentData: [],
    };
  },
  methods: {
    //返回课程具体信息
    returnCourseDetail() {
      let options = { sections: this.$store.state.temp_courseSections };
      this.$http
        .post(this.$api.CourseMonitorGETCourseOfT, options)
        .then((resp) => {
          if (resp.success) {
            this.courseData = resp.data;
          } else {
            this.$handleFailResp(this, resp);
          }
        });
    },
    //返回上课学生列表名单
    returnStudensList() {
      let options = { sections: this.$store.state.temp_courseSections };
      this.$http
        .post(this.$api.CourseMonitorSearchStudentList, options)
        .then((resp) => {
          if (resp.success) {
            this.courseStudentData = resp.data;
          } else {
            this.$handleFailResp(this, resp);
          }
        });
    },
  },
  mounted() {
    this.returnCourseDetail();
    this.returnStudensList();
  },
};
</script>

<style lang="less" scoped>
.el-input {
  width: 150px;
}

/deep/ .el-input.is-disabled .el-input__inner {
  color: black;
  border: 1px solid #8595a6;
  border-radius: 1px;
  //background-color: #edeff1;
  padding: 5px;
}

/deep/ .el-input__inner {
  color: #333333;
  border: 1px solid #8595a6;
  border-radius: 1px;
  //background-color: #fff;
  padding: 5px;
}

/deep/ .el-form-item__label {
  margin-right: 0px;
  text-align: center;
  font-size: 15px;
  color: #333333;
}

/deep/.el-input--small .el-input__inner {
  height: 25px;
}

.el-form-item {
  margin-bottom: 0px;
}

/deep/ .el-form-item__content {
  padding: 0;
}

.courseData {
  margin-top: 10px;
  width: 450px !important;
}

// 弹窗的样式
/deep/ .el-dialog__title {
  font-size: 23px;
  color: rgb(51, 55, 68);
}

// 表格样式
.studentTable {
  text-align: center !important;
  height: 450px !important;
}

// 滚动条样式
/deep/ .gutter {
  width: 10px !important;
}

.el-table__body-wrapper is-scrolling-none {
  height: 100%;
}

/deep/ .el-dialog--center .el-dialog__body {
  padding: 10px 25px 30px;
}
</style>
